package com.patternsbox.structural.flyweight;

import com.patternsbox.ActionTemplate;

public class FlyweightAction extends ActionTemplate {

	@Override
	protected void doAction() {
		// Arbitrary extrinsic state
		int extrinsicstate = 22;
		FlyweightFactory factory = new FlyweightFactory();
		// Work with different flyweight instances
		Flyweight fx = factory.getFlyweight("X");
		fx.operation(--extrinsicstate);
		Flyweight fy = factory.getFlyweight("Y");
		fy.operation(--extrinsicstate);
		Flyweight fz = factory.getFlyweight("Z");
		fz.operation(--extrinsicstate);
		Flyweight fu = new UnsharedConcreteFlyweight();
		fu.operation(--extrinsicstate);
	}
}
